<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .slider {
            position: relative;
            width: 600px;
            height: 300px;
            margin: 150px auto;
        }

        .slider-outer {
            width: 600px;
            height: 300px;
            /*border: 1px solid red;*/
        }

        .slider-item {
            width: 50px;
            height: 100%;
            transform-style: preserve-3d;
            transition: 2s;
            position: absolute;
        }

        .img {
            width: 100%;
            height: 100%;
            position: absolute;
        }

        .img:nth-child(1) {
            background: url("images/1-1.jpg");
            transform: rotateX(0deg) translateZ(150px);

        }

        .img:nth-child(2) {
            background: url("images/1-2.jpg");
            transform: rotateX(90deg) translateZ(150px);
        }

        .img:nth-child(3) {
            background: url("images/1-3.jpg");
            transform: rotateX(180deg) translateZ(150px);
        }

        .img:nth-child(4) {
            background: url("images/1-4.jpg");
            transform: rotateX(270deg) translateZ(150px);
        }

        .btns {
            height: 50px;
            width: 100%;
            position: absolute;
            top: 125px;
        }

        .prev, .next {
            width: 50px;
            position: absolute;
            height: 50px;
            font-size: 30px;
            color: #ffffff;
            background: rgba(0, 0, 0, 0.3);
            text-align: center;
            line-height: 50px;
        }

        .prev {
            left: 0;
        }

        .next {
            right: 0;
        }
    </style>
</head>
<body>
<div class="slider">
    <div class="slider-outer">
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
    </div>
    <div class="btns">
        <div class="prev" id="prev">&lt;</div>
        <div class="next" id="next">&gt;</div>
    </div>
</div>
<script>
    var items = document.getElementsByClassName("slider-item"), num = 0;
    for (var i = 0; i < items.length; i++) {
        var item = items[i];
        item.style["left"] = i * item.offsetWidth + "px";
        item.style["transitionDelay"] = i * .3+ "s";
        var sub = item.children;
        for (var j = 0; j < sub.length; j++) {
            sub[j].style["backgroundPosition"] = -i * item.offsetWidth + "px";
        }
    }
    document.getElementById("prev").onclick = function (e) {
        var rotate = ++num * 90;
        for (var i = 0; i < items.length; i++) {
            items[i].style["transform"] = "rotateX(" + rotate + "deg)"
        }
    };
    document.getElementById("next").onclick = function (e) {
        var rotate = --num * 90;
        for (var i = 0; i < items.length; i++) {
            items[i].style["transform"] = "rotateX(" + rotate + "deg)";
        }
    };


</script>
</body>
</html>